package com.zjf.carpark.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class Interceptor implements WebMvcConfigurer {

    /**
     * 重写注册方法
     *
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/desk/login",
                        "/user/checkCode",
                        "/user/login",
                        "/desk/ownerLogin",
                        "/desk/parkPlace",
                        "/weiXin/login",
                        "/static/assets/**",
                        "/desk/barChart",
                        "/desk/advise",
                        "/desk/announcement",
                        "/parkPlace/selectAllParkPlace",
                        "/announcement/showAllRelease",
                        "/desk/oneAnnouncement",
                        "/announcement/showOne",
                        "/tAdvise/*",
                        "/tOrder/*"
                );
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        //第一个方法设置访问路径前缀，第二个方法设置资源路径
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
    }
}
